package com.tool.builder.BuildTemplate;

import com.tool.bean.Constants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.*;
import java.util.Locale;

import static com.tool.utils.writeToFileUtils.writeToFile;

public class BuildR {

    private static Logger logger = LoggerFactory.getLogger(Locale.Builder.class);
    public static void execute() {

        File folder = new File(Constants.COMMON_PATH_R);
        if (!folder.exists()) {
            folder.mkdirs();
        }

        // 定义目标文件
        File RFile = new File(folder, "R.java");

        // 模板路径
        String RTemplatePath = BuildR.class.getClassLoader()
                .getResource("template/R.txt").getPath();

        // 写入文件逻辑
        try {
            // 写入 R 文件
            writeToFile(RTemplatePath, RFile, Constants.COMMON_PACKAGE_R);

        }   catch (Exception e) {
            logger.error("生成R类失败:{}", e);
        }
    }


}